import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { shopSalesPackageListData } from '/@/api/shop/sales/shopSalesPackage';
const { t } = useI18n('setting.pricemodel.wecharPriceModel');

const modalProps = {
  title: t('套餐包选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  showResetButton: false,
  schemas: [
    {
      label: t('标题'),
      field: 'title',
      component: 'Input',
    },
    {
      label: t('生效日期'),
      field: 'beginDate',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
    {
      label: t('失效日期'),
      field: 'endDate',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
    {
      label: t('状态'),
      field: 'fbStatus',
      component: 'Select',
      componentProps: {
        dictType: 'shop_fb_status',
        allowClear: true,
      },
    },
    {
      label: t('套餐介绍'),
      field: 'remarks',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('标题'),
    dataIndex: 'title',
    key: 'a.title',
    sorter: true,
    width: 100,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('生效日期'),
    dataIndex: 'beginDate',
    key: 'a.beginDate',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('失效日期'),
    dataIndex: 'endDate',
    key: 'a.endDate',
    sorter: true,
    width: 150,
    align: 'left',
  },
  // {
  //   title: t('套餐介绍'),
  //   dataIndex: 'remarks',
  //   key: 'a.remarks',
  //   sorter: true,
  //   width: 200,
  //   align: 'left',
  // },
  // {
  //   title: t('创建时间'),
  //   dataIndex: 'createDate',
  //   key: 'a.create_date',
  //   sorter: true,
  //   width: 130,
  //   align: 'center',
  // },
  {
    title: t('状态'),
    dataIndex: 'fbStatus',
    key: 'a.fb_status',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'shop_fb_status',
  },
];

const tableProps: BasicTableProps = {
  api: shopSalesPackageListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    params['fbStatus'] = 1;
    return params;
  },
  ellipsis: false,
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'id',
  itemName: 'title',
};
